﻿namespace Jim.OA.Service;

/// <summary>
/// 授权
/// </summary>
/// <remarks>需要提前在OA中注册Appkey</remarks>  
[ApiDescriptionSettings(ApplicationConst.GroupName)]
public  class OATokenService : IDynamicApiController, ITransient
{
    private readonly OAClientFactory _oaClientFactory;
    public OATokenService(OAClientFactory oaClientFactory)
    {
        _oaClientFactory = oaClientFactory;
    }

    /// <summary>
    /// 注册接口
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [NonUnify]
    public async Task<OARegistOutput> OARegist(OARegistInput input)
    {
        var client = _oaClientFactory.CreateRestClient();
        client.IsDebug = true;
        var result = await client.Execute(input);
        return result;
    }


    /// <summary>
    /// 用Regist接口信息换区Token
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [NonUnify]
    public async Task<OATokenOutput> OAToken(OATokenInput input)
    {
        var client = _oaClientFactory.CreateRestClient();
        client.IsDebug = true;
        var result = await client.Execute(input);
        return result;
    }
}
